import 'package:flutter/material.dart';
// 对齐与相对定位（Align）

class AlignRoute extends StatefulWidget {
  @override
  _AlignRouteState createState() => _AlignRouteState();
}

class _AlignRouteState extends State<AlignRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("对齐与相对定位 Align、Center"),
        ),
        body: _AlignRouteBody());
  }
}

class _AlignRouteBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Text("Container width、height限制高度--------"),
        Container(
          height: 120.0,
          width: 120.0,
          color: Colors.blue[100],
          child: Align(
            alignment: Alignment.centerLeft,
            child: FlutterLogo(
              size: 60,
            ),
          ),
        ),
        Text("--------Align widthFactor--------"),
        Container(
          color: Colors.blue[100],
          child: Align(
            alignment: Alignment.topCenter,
            widthFactor: 2,
            heightFactor: 2,
            child: FlutterLogo(
              size: 60,
            ),
          ),
        ),
        Text("--------Align Alignment(x,y)--------"),
        Container(
          color: Colors.blue[100],
          child: Align(
            alignment: Alignment(2.0, 0.0),
            widthFactor: 2,
            heightFactor: 2,
            child: FlutterLogo(
              size: 60,
            ),
          ),
        ),
        Text("--------Align FractionalOffset(x,y)--------"),
        Container(
          color: Colors.blue[100],
          height: 120.0,
          width: 120.0,
          child: Align(
            alignment: FractionalOffset(0.6, 0.6),
            child: FlutterLogo(
              size: 60,
            ),
          ),
        ),
        Text("--------Center--------"),
        DecoratedBox(
          decoration: BoxDecoration(color: Colors.red),
          child: Center(
            child: Text("Center xxxx"),
          ),
        ),
        Text("--------Center widthFactor--------"),
        DecoratedBox(
          decoration: BoxDecoration(color: Colors.red),
          child: Center(
            widthFactor: 1,
            heightFactor: 1,
            child: Text("Center widthFactor xxxx"),
          ),
        )
      ],
    );
  }
}
